from django.db import models
from models import BaseModel
# Create your models here.

class Nav(BaseModel):
    POSITION = (
        (0, '顶部导航'),
        (1, '底部导航'),
    )
    link=models.CharField(max_length=100,verbose_name='链接')
    is_http=models.CharField(max_length=100,verbose_name='是否外部链接')
    position=models.BooleanField(default=0,choices=POSITION,verbose_name='导航位置')
    class Meta:
        db_table='fg_nav'
        verbose_name='导航菜单'
        verbose_name_plural=verbose_name
class Category(BaseModel):
    cname=models.CharField(max_length=50,verbose_name='分类名称')
    ishot=models.IntegerField(default=0,verbose_name='是否热门')
    isgood=models.IntegerField(default=0,verbose_name='是否推荐')
    ishome=models.IntegerField(default=0,verbose_name='是否首页展示')
    parent=models.ForeignKey('self',on_delete=models.CASCADE,null=True,blank=True,verbose_name='父级分类',related_name="children")
    class Meta:
        db_table='fg_category'
        verbose_name='分类'
        verbose_name_plural=verbose_name
class Banner(BaseModel):
    image=models.ImageField(upload_to='banner/%Y/',verbose_name='轮播图路径')
    link=models.CharField(max_length=100,verbose_name='跳转的链接')
    is_http=models.BooleanField(default=False,verbose_name='是否外部链接')
    note=models.CharField(max_length=100,verbose_name='备注')
    class Meta:
        db_table='fg_banner'
        verbose_name='轮播图'
        verbose_name_plural=verbose_name

class Cate(BaseModel):
    image=models.ImageField(upload_to='avatar/2021/',verbose_name='图片路径')
    class Meta:
        db_table='fg_cate'
        verbose_name='分类'
        verbose_name_plural=verbose_name
class Categorys(BaseModel):
    link=models.CharField(max_length=100,verbose_name='跳转的链接')
    is_http=models.BooleanField(default=False,verbose_name='是否外部链接')
    cate=models.ForeignKey(Cate,on_delete=models.CASCADE,verbose_name='分类')
    class Meta:
        db_table="fg_categorys"
        verbose_name='分类们'
        verbose_name_plural=verbose_name
class CategoryGoods(BaseModel):
    image=models.ImageField(upload_to='course/cover/',verbose_name='图片路径')
    description=models.CharField(max_length=100,verbose_name='描述')
    jb=models.CharField(max_length=100,verbose_name='级别')
    number=models.IntegerField(verbose_name='报名人数')
    price=models.DecimalField(max_digits=9,decimal_places=2,verbose_name='价格')
    categoods=models.ForeignKey(Categorys,on_delete=models.CASCADE,verbose_name='分类们')
    class Meta:
        db_table="fg_categorygoods"
        verbose_name='分类商品'
        verbose_name_plural=verbose_name

class Fx(BaseModel):
    image=models.ImageField(upload_to='avatar/2021/',verbose_name='图片路径')
    description=models.CharField(max_length=100,verbose_name='描述')
    class Meta:
        db_table="fg_fx"
        verbose_name='方向类'
        verbose_name_plural=verbose_name